﻿using Aop.Api;
using Aop.Api.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace testali
{
    internal static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            var config = new AlipayConfig
            {
                AppId = "2016092000553314",
                Charset = "utf-8",
                PrivateKey = "MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQDD6g3FbQTMsZqjMtwIBlNlc5eL5n6y8ni9DLyNjPlhmY9Ri0JVEjftHZFJ0/hbnBShA/CckOvTwOkwzuDup771KnojDfaiXsxiPOT9cgRildMDM3zp85h3T9H+uQZUr5KJjJFouB4MlOBpvflAukGNsfauoBvqO0nZfT2Mrg5pmIvYsO+OKHNnTEn+aFtZKYX+t4ibQvU+0ZF2KZ0z34M88OisbfIV0WL8eWeUklR/tSsoe3U2jWJvYDnM0OwpMVAeNgJaaGTSFoLqsyfw2MxB5W9VZOEX7wApUNyvMk9q/ILpoDx57ps8MKL9q2xYrkGPcRuqlSxWSgaWwBot65zjAgMBAAECggEBAIMyimZby4sIpPYFaTQ2iEK4VhRqFw7fMdvoW5yve5HQtBl3mMQ/nxQ7aMB4Iym2LFpnuQogQs1bss3svNUVoNutxn0TLMcvlM902CSh5i3fB6BtKonBh6je21IptgOgUBGtAPOP2Q+z41Ts0651DNFHDFuE/Syu55WuOTmslho/0AYAG9YXFliakTJAyi4mEeQsYSz6+yGpmxE8QQrHAJv3urE6Y02TsT8Wvhw/b+Ttfto0qRD83tf5riiV4No3o+HpBf/nhBb/f2IOQ0E34VM8gENBkf354KnjT0UZtyo6x7L5xKDNAOEWX9Exg3NsS4pap86+QW6fZZDiqGB074ECgYEA+tVJbsTuH3jLmAXfu+4zR/FFmBVxJn8A0lcnTbmYoC3nrXB18DOkqevVraatZLcVV2NYEKXuAl1Tq7XRbP98RWRa8+a7FkWMg0I3oCj+kv2s99HuZh3+yezi+4aOl39j6+WEnQQGqbIbDrECbjXUIUz2UoMomcP4WE0esgcDe38CgYEAx/MqFQyAKIkkhdhS4uaG/p9rv6hHujyRZUahg/sF9Q3GLsTyAgYQuzIBKhe4QTvmdG/Qxy4gWzBspcg0i6sasAxgSIsd7lYDqWnfdEcuTD2bX+cgfoaD3Y1SYzWnMYEYz929yI6JBMa0mxF7a9yTwywjUwnlnlliRNMmEN8nIJ0CgYEAoxNn2oxOBEgUlZG8FAKZdHx4Mpg+KDkJ37ap5u5zPDCcHzaudqwcshyRn4Rt1rzxMw9zgd9fDkp+y3Q55BN2R+cm+stXdvNglzXF1GrSl941RilGRT3bGIzaRY0Fx5ka7ZMa1Lp5Wnpg/Pw4CE8Wy0+uFZcQHmg6Xa5F9ph4uyECgYEApOHdcuwTBtpItuKzPw6whWm7NZm0RFxL3YMID8jBmdmY8tpPYuHTjDppAWf79jdKC/xk4ssjvW7KOU9GHWKkqEYcY9XsgayGan622LEV+aLX7JawkgWk2d7+8Ha+/7CgYFFPfgIj9T9SkYkyCLklVE2id4hyxEibI3wnKMSMBHUCgYEAkwGy+9yR5MttaH+0R1FzprNupC2fv3OdxH8+RfYwL/J+huNHv6dkc1QSZloNeBeFxkvXIsVocJow+3Zz61pZCqbBmAKuPhR+o/oU7NcoUABghU373EBRRue7tjUGywRtTq6bM84hCTKSwCb6fty7U7TTpw1Ee2zn25p5Ej0tmDM=",
                SignType = "RSA2",
                Format = "json",
                ServerUrl = "test.tztjt.com/open_platform_provider/open/api/exchange",
            };

            // 添加生成签名的示例
            string content = "example_content";
            string sign = GenerateSign(content, config);
            Console.WriteLine($"生成的签名: {sign}");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }

        // 修改后的生成签名方法
        static string GenerateSign(string content, AlipayConfig config)
        {
            byte[] data = Encoding.UTF8.GetBytes(content);
            return AlipaySignature.RSASignCharSet(content, config.PrivateKey, config.Charset, config.SignType,false);
        }
    }
}
